#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool lexicographically(vector<string> &s)  //按字典排序，有序返回true
{
    int len = s.size();
    for(int i = 0; i < len - 1; ++i){
        int minlen = min(s[i].size(), s[i+1].size());
        if(s[i].compare(s[i+1]) > 0){
            return false;
        }
    }
    return true;
}

bool lengths(vector<string> &s)  //按长度排序，有序返回true
{
    for(int i = 1; i < s.size(); ++i){
        if(s[i].size() < s[i-1].size()){
            return false;
        }
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    if(n < 2){
        cout << "both";
        return 0;
    }
    vector<string> str (n);
    for(int i = 0; i < n; ++i){
        cin >> str[i];
    }
    bool lex = lexicographically(str);
    bool len = lengths(str);
    if(lex && len){
        cout << "both";
    }
    else if(lex && !len){
        cout << "lexicographically";
    }
    else if(!lex && len){
        cout << "lengths";
    }
    else if(!lex && !len){
        cout << "none";
    }

    return 0;
}